package cn.itsource.mq.transaction.listener;

import org.apache.rocketmq.client.producer.LocalTransactionState;
import org.apache.rocketmq.client.producer.TransactionListener;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageExt;

public class MyTransactionListener implements TransactionListener {
    //执行本地事务
    @Override
    public LocalTransactionState executeLocalTransaction(Message message, Object o) {
        excuteTransaction();
        System.out.println(o);
        return LocalTransactionState.COMMIT_MESSAGE;
    }

    //检查本地事务是否执行成功
    @Override
    public LocalTransactionState checkLocalTransaction(MessageExt messageExt) {
        return null;
    }

    private void excuteTransaction(){
        System.out.println("执行本地事务");
    }
}
